package mulegame;

import java.io.*;

/**
 * 
 * exception handling for possible errors and prints results, says logging has started
 * 
 * @author AREA 29
 *
 */
public class Logger{
	
    public static PrintStream logger;
    /**
     *exception handling for possible errors
     */
    public Logger(){
      /*  This section can be used to send logger output to text file
      try{
         logger = new PrintStream("logs" + File.pathSeparator + "log.txt");
      } catch (FileNotFoundException e){
         System.out.println("Cannot use log file, reverting to System.out\n" + e.toString());
         logger = System.out;
      } catch (SecurityException e){
         System.out.println("Security exception generated, reverting to System.out" + e.toString());
         logger = System.out;
      } catch (Exception e){
         System.out.println("Unknown exception generated:");
         e.printStackTrace();
         //this error is unrecoverable, so return
         return;
      }       
      */
      //uncomment to force logger to be System.out
      logger = System.out;
      logger.println("logging started");
    }
    /**
     * Logger prints the parameter toPrint
     * 
     * @param toPrint
     */
    public static void println(String toPrint){
      logger.println(toPrint);   
    }
}
